<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    #btn {
      width: 60px;
      height: 30px;
      /* border: 1px solid; */
      display: flex;
      justify-content: center;
      align-items: center;
      cursor: pointer;
      box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04)
    }
  </style>
</head>
<body>
  <div id="app"></div>
  <!-- <div id="btn">++</div>
  <p id="box">123</p> -->
  
  <!-- <script src="https://unpkg.com/@vue/reactivity@3.0.5/dist/reactivity.global.js"></script> -->
  <!-- <script src="./compiler/index.js"></script> -->

  <script type="module">
    import { renderer, normalizeClass } from './compiler/index.js'
    import { effect, ref, reactive } from './reactivity/reactivity.js'

    // const { effect, ref } = VueReactivity

    const myComp = {
      name: 'MyComp',
      props: {
        title: String
      },
      data() {
        return {foo: 1}
      },
      created() {
        // console.log(this, 'this')
      },
      mounted() {
        // console.log(this, 'jkjfks')
        // this.foo = 9
      },
      render(ctx) {
        console.log(ctx)
        // this.foo = 2
        return {
          type: 'div',
          children: `foo 的值：${ctx.title}`
        }
      }
    }

    const oldVnode = {
      type: myComp,
      props: {
        title: 'A big title'
      }
    }

    const container = document.querySelector('#app')

    const foo = reactive({
      bar: {
        kk: 123
      }
    })

    effect(() => {
      renderer.render(oldVnode, container)
      // foo.bar = '000'

      // setTimeout(() => {
      //   renderer.render(newVnode, container)
      // }, 1000)

    }, {
      scheduler: () => {
        console.log('33')
      }
    })

  </script>
</body>
</html>
